<?PHP
//written by Slyferz

include("includes/killsql.php");
$result = mysql_query("SELECT distinct plt_name, plt_externalid FROM kb3_pilots WHERE plt_crp_id = 500 ORDER BY plt_name");
for($i = 0; $row = mysql_fetch_array($result); $i++)
{
	$list[$i][0] = $row['plt_name'];
	$list[$i][1] = $row['plt_externalid'];
}	
mysql_close();

$toggle = 1;
include("includes/database.php");
$result = mysql_query("SELECT distinct name, realID, charID FROM characters WHERE inCorp = 1 ORDER BY name");
while($row = mysql_fetch_array($result))
{
	for($i = 0; !empty($row[$i][0]); $i++)
		if($list[$i][1] == $row['realID'])
			$toggle = 2;
	if($toggle == 1)
		for($i = 0; !empty($list[$i][0]); $i++)
			if($row['name'] == $list[$i][0])
		//mysql_query("UPDATE characters SET realID = '".$list[$row['name']]."' WHERE name = '".$row['name']."'");
				echo " ".$row['name']." ";
	//	mysql_query("UPDATE characters SET realID = '".$row['charID']."' WHERE name = '".$row['name']."'");
}

?>
